package main

import "fmt"

func f(s []byte) {
	if len(s) == 0 {
		return
	}
	core(s, 0)
}

func core(s []byte, loc int) {
	if loc == len(s) {
		fmt.Println(string(s))
	}

	for i := loc; i < len(s); i++ {
		s[loc], s[i] = s[i], s[loc]
		core(s, loc+1)
		s[i], s[loc] = s[loc], s[i]
	}
}

func main() {
	s := "abc"
	f([]byte(s))
}
